package main

import (
	"context"
	"encoding/json"
	"fmt"
	"github.com/micro/go-micro/v2"
	api "github.com/micro/go-micro/v2/api/proto"
	user "my_micro/userserver/db"
)

type User2 struct {
	Client user.UserService
}

func (s User2) GetUser(ctx context.Context, req *user.GetUserReq, rep *user.GetUserRep) error{
	return nil
}

func (s *User2) Test(ctx context.Context, in *api.Request, out *api.Response) error {
	fmt.Println("ffffffffffffffffff")
	out.StatusCode = 200
	b, _ := json.Marshal(map[string]string{
		"message": "dddddddd",
	})
	out.Body = string(b)
	return nil
}

func (s *User2) DeleteUser(ctx context.Context, req *user.DeleteUserReq, rsp *user.DeleteUserRep) error {
	return nil
}

func (s *User2) InsertUser(ctx context.Context, req *user.InsertUserReq, rsp *user.InsertUserRep) error {
	return nil
}
func (s *User2) ModifyUser(ctx context.Context, req *user.ModifyUserReq, rsp *user.ModifyUserRep) error {
	return nil
}

func main() {
	ser := micro.NewService(
		micro.Name("go.micro.api.userserver"),
		micro.Version("latest"),
	)
	ser.Init()
	d := user.NewUserService("go.micro.api.userserver", ser.Client())
	_ = ser.Server().Handle(ser.Server().NewHandler(&User2{Client: d}))


	if err := ser.Run(); err != nil {
		fmt.Println("micro stop")
	}
}